package com.googlecode.publicholiday.repository.jdbc;

import com.googlecode.publicholiday.repository.ImmutablePublicHolidayRepository;
import org.joda.time.LocalDate;

import java.util.Collection;

public abstract class AbstractJdbcImmutablePublicHolidayRepository implements ImmutablePublicHolidayRepository {

    private final static String SELECT_PUBLIC_HOLIDAY_ON_DATE_SQL = "" +
            "SELECT holiday_date " +
            "FROM   public_holiday " +
            "WHERE  country_code = ? " +
            "AND    holiday_date = ? ";
    private final static String SELECT_PUBLIC_HOLIDAYS_BETWEEN_DATES_SQL = "" +
            "SELECT holiday_date " +
            "FROM   public_holiday " +
            "WHERE  country_code  = ? " +
            "AND    holiday_date >= ? " +
            "AND    holiday_date  < ? " +
            "ORDER BY holiday_date ASC";

    protected String getPublicHolidayOnDateSqlStatement() {
        return SELECT_PUBLIC_HOLIDAY_ON_DATE_SQL;
    }

    protected String getPublicHolidaysBetweenDatesSqlStatement() {
        return SELECT_PUBLIC_HOLIDAYS_BETWEEN_DATES_SQL;
    }

    @Override
    public abstract LocalDate find(String countryCode, LocalDate publicHoliday);

    @Override
    public abstract Iterable<LocalDate> find(String countryCode, LocalDate startDate, LocalDate endDate);

}
